#    Copyright 2008, 2009 Tri-County Electric Cooperative, St. Matthews, South Carolina
#    This file is part of COOPIP.
#    COOPIP is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    COOPIP is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with COOPIP.  If not, see <http://www.gnu.org/licenses/>.
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
from reportlab.platypus import Flowable

class LastPageNumberFlowable(Flowable):
    def __init__(self, dx = 0, dy = 0):
        Flowable.__init__(self)
        self.dx = dx
        self.dy = dy
    def draw(self, Font='Times-Roman', Points=10):
        canvas = self.canv
        if not canvas.hasForm("LastPageNumber"):
            canvas.beginForm('LastPageNumber')
            canvas.setFont(Font, Points)
            canvas.drawRightString(self.dx, self.dy, str(canvas.getPageNumber()))
            canvas.endForm()
